#ifndef INSTANCE_H
#define INSTANCE_H

#include <boost/dynamic_bitset.hpp>

#include <stdint.h>
#include <iostream>

#include <boost/archive/text_oarchive.hpp> 
#include <boost/archive/text_iarchive.hpp> 

#include "dynamic_bitset.hpp"

using namespace std;

class Instance {
  private:
    uint16_t pNumber;			            //celkovy pocet uzlu
    uint16_t pRegularity;		          //max stupen uzlu
    boost::dynamic_bitset<> pBitSet;	//uzly

    /* BOOST SERIALIZATION */
    friend class boost::serialization::access;
    template<class Archive> 
    void serialize(Archive& aAr, const unsigned int version) { 
      aAr & pNumber;
      aAr & pRegularity;
      aAr & pBitSet; 
    }
 
  public: //lifetime
    Instance(uint16_t aNumber = 0)
      : pNumber(aNumber)
      , pRegularity(0)
      , pBitSet(aNumber)
    {
    }

    ~Instance() {
    }

  public: //own methods
    friend ostream &operator<<(ostream &aOut, const Instance& aInstance);
    friend istream &operator>>(istream &aIn, Instance& aInstance);

    bool operator() (uint16_t aRow, uint16_t aCol)
    {
      /* range checking, disabled for greater speed */
      //if (aRow >= pNumber || aCol >= pNumber)
      //throw "Instance subscript out of bounds";
      return pBitSet[pNumber*aRow + aCol];
    }

    //vrat pocet nodu
    uint16_t getNumber() const {
      return pNumber;
    }

    //vrat regularitu (maximalni stupen)
    uint16_t getRegularity() const {
      return pRegularity;
    }
};

#endif
// vim: ts=2 fdm=marker syntax=cpp expandtab sw=2
